﻿//页面加载
$(document).ready(function () {
    $("#btnSave").bind("click", btnSave_click);
    $("#btnCancel").bind("click", btnCancel_click);
})

function btnSave_click() {
    //异步提交表单,表单中input元素必须设置name 属性
    var v_oldPwd = $("#oldPassword").val();
    var v_pwd1 = $("#Password").val();
    var v_pwd2 = $("#Password2").val();
    if (v_oldPwd == "") {
        $("#msg").html("原密码不能为空");
        return;
    }
    if (v_pwd1 == "" || v_pwd2 == "") {
        $("#msg").html("新密码或确认密码不能为空");
        return;
    }
    if (v_pwd1 != v_pwd2) {
        $("#msg").html("新密码两次输入不一致");
        return;
    }
    var v_cardCode = $("#Code").val();
    $.post("/WeChatProduct/SavePassword", { cardCode: v_cardCode, oldPassword: v_oldPwd, newPassword: v_pwd1, newPassword2: v_pwd2 }, function (result) {
        if (result.code == "OK") {
            alert("绑定成功!");
            window.location.href = "/WeChatProduct/Index";
        }
        else {
            $("#msg").html(result.msg);
            $("#msg").css("color", "red");
        }
    }, "json");
}

function btnCancel_click() {
    window.history.go(-1);
}